﻿function showupload()
{
	$("#uploaddlg").dialog("open");
	return false;
}

function showbasicinfoerror()
{
	var s = "歌名：<input id='namemodify' type='text' value='"+readCookie("name")+"'/><br/>\
					歌手：<input id='singermodify' type='text' value='"+readCookie("singer")+"'/><br/>\
					专辑：<input id='albummodify' type='text' value='"+readCookie("album")+"'/><br/>\
					<a id='clickmodifybasic'>修改</a>"
				
	$("#basicinfoerrordlg").html(s);
	//in ie the clickmodifybasic has no click type
	$("#basicinfoerrordlg").dialog("open");
	$("#clickmodifybasic").click(modifybasicinfo);
	return false;
}

function showlyricerror()
{
	$("#clickmodifylyric").click(modifylyric);
	$("#lyricerrordlg").dialog("open");
	return false;
}

//call the rpc
//ajax
function modifybasicinfo()
{
	//check which info is modified
	$.getJSON(appurlprefix+"/correct/musicbasic?musicid="+readCookie("key")+"&name="+$("#namemodify").attr("value")+"&singer="+$("#singermodify").attr("value")+"&album="+$("#albummodify").attr("value"),postmodifybasicinfo);
}

//next step after get the modify 
function postmodifybasicinfo(data)
{
	//check the return info
	if(data.status == "ok")
	{
		$("#basicinfoerrordlg").html("修改成功");
	}
	else
		{
			$("#basicinfoerrordlg").html("修改失败");
		}
}

//call the rpc
//ajax
function modifylyric()
{
	//simple moidfy the lyric
	//how to transfer this?
	$.getJSON(appurlprefix+"/correct/musiclyric?musicid="+readCookie("key")+"&lyric="+$("#lyricerrortext").attr("value"),postmodifylyric);
}

//next step after get the modify 
function postmodifylyric(data)
{
	if(data.status == "ok")
	{
		$("#lyricerrordlg").html("歌词修改成功");
	}
	else
	{
		$("#lyricerrordlg").html("歌词修改失败");
	}
}

/**
 * showmodify info of one music
 *
 */
function showmodifyofmusic()
{
	//the dlg pattern
	$("#showmodifydlg").dialog("open");
	$.getJSON(appurlprefix+"/correct/showmodify?musicid="+readCookie("key"),postshowmodify);
	return false;
}

function postshowmodify(datat)
{
	//
	if(datat.status == "error")
	{
		if(datat.errordesp == "norecord")
		{
			$("#showmodifydlg").html("没有记录");
		}
		else
		{
			$("#showmodifydlg").html(datat.errordesp);
		}
	}
	else if(datat.status == "ok")
	{
		$("#showmodifydlg").html(datat.htmlcode);
	}
	else
	{
		$("#showmodifydlg").html("未知错误");
	}
}